package com.dmx.fw.web.struts2.components;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.TextArea;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;

import com.opensymphony.xwork2.util.ValueStack;

@StrutsTag(name = "textarea", tldTagClass = "com.dmx.fw.web.struts2.views.tags.ExtTextAreaTag", description = "Render HTML textarea tag", allowDynamicAttributes = true)
public class ExtTextArea extends TextArea {

	protected String pageState;
	protected String addState;
	protected String editState;
	protected String viewState;
	protected String code;
	protected String params;
	protected String outHidden;

	public ExtTextArea(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		super(stack, request, response);
		// TODO Auto-generated constructor stub
	}

	protected String getDefaultTemplate() {
		return "exttextarea";
	}

	public void evaluateExtraParams() {
		super.evaluateExtraParams();

		if (pageState != null) {
			addParameter("pageState", findString(pageState));
		}
		if (addState != null) {
			addParameter("addState", findString(addState));
		}
		if (editState != null) {
			addParameter("editState", findString(editState));
		}
		if (viewState != null) {
			addParameter("viewState", findString(viewState));
		}
		if (code != null) {
			addParameter("code", findString(code));
		}
		if (params != null) {
			addParameter("params", findString(params));
		}
		if (outHidden != null) {
			addParameter("outHidden", findString(outHidden));
		}
	}

	@StrutsTagAttribute(description = "pageState attribute", type = "String")
	public void setPageState(String pageState) {
		this.pageState = pageState;
	}

	@StrutsTagAttribute(description = "addState attribute", type = "String")
	public void setAddState(String addState) {
		this.addState = addState;
	}

	@StrutsTagAttribute(description = "editState attribute", type = "String")
	public void setEditState(String editState) {
		this.editState = editState;
	}

	@StrutsTagAttribute(description = "viewState attribute", type = "String")
	public void setViewState(String viewState) {
		this.viewState = viewState;
	}

	@StrutsTagAttribute(description = "code attribute", type = "String")
	public void setCode(String code) {
		this.code = code;
	}

	@StrutsTagAttribute(description = "params attribute", type = "String")
	public void setParams(String params) {
		this.params = params;
	}

	@StrutsTagAttribute(description = "outHidden attribute", type = "Boolean")
	public void setOutHidden(String outHidden) {
		this.outHidden = outHidden;
	}

}
